package security.Authentication.Guest;

import security.Authentication.Base.AuthenticationHandler;
import security.Authentication.Base.AuthenticationRequest;
import security.Authentication.Base.IdentifiedUser;
import security.Authentication.Base.User;
import security.Authorization.Base.AuthorizationLevel;


/**
 * An authentication handler that accepts guests
 * @author Andreas Carmvall
 */
public class GuestHandler extends AuthenticationHandler {

	@Override
	public User handleRequest(AuthenticationRequest request) {
		if (request instanceof GuestRequest) {
			// No check is needed for a guest request
			return new IdentifiedUser(AuthorizationLevel.GUEST);
		} else {
			return passRequestToNext(request);
		}
	}

}
